package com.czk.service;

import com.czk.pojo.User;
import org.springframework.util.StringUtils;

/**
 * 本地存根的调用
 * 此时会为在本地生成userService的实现，成为本地存根
 *
 * @Author:ChenZhangKun
 * @Date: 2021/3/23 16:23
 */

public class UserServiceSub implements UserService {
    private final UserService userService;

    /**
     * dubbo会自动传入userService的远程代理对象
     *
     * @param userService
     */
    public UserServiceSub(UserService userService) {
        super();
        this.userService = userService;
    }

    @Override
    public User getUserByName(String username) {
        System.out.println("本地存根被调用了");
        if (!StringUtils.isEmpty(username)) {
            //
            return userService.getUserByName(username);
        }
        return null;
    }
}
